﻿var status = -1;
var isSecond = false;

//价格：发型，脸型（余额）
var Cash = [[30, 5150088], [30, 5152085]];

//男发型
var mhair = [44611,44520,44516,44420,40931,44177,44165,40780,40760,40750,40660,40650,40600,40590,40560,40550,40530,40510,40520,40430,40400,40380,40390,40340,40300,40290,40250,40090,40060,40030,40020,40010,36920,36720,36510,36300,36280,36200,35750,35630,35290,35240,35220,35210,35180,35150,33970,33780,33480,33440,33430,33400,33340,33320,33310,33270,33240,33220,33210,33200,33190,33180,33130,33090,33060,33000,32120,30800,30780,30730,30570,30560,30490,30440,30360,30350,30340,30280,30210,30060,30040];

var mhair1 = [44611,44520,44516,44420,40931,44177,44165,40780,40760,40750,40660,40650,40600,40590,40560,40550,40530,40510,40520,40430,40400,40380,40390,40340,40300,40290,40250,40090,40060,40030,40020,40010,36920,36720,36510,36300,36280,36200,35750,35630,35290,35240,35220,35210,35180,35150,33970,33780,33480,33440,33430,33400,33340,33320,33310,33270,33240,33220,33210,33200,33190,33180,33130,33090,33060,33000,32120,30800,30780,30730,30570,30560,30490,30440,30360,30350,30340,30280,30210,30060,30040];

//女发型
var fhair = [44611,44520,44516,44420,37321,34872,34211,44400,41540,38930,44110,44070,44060,44050,44040,42090,42070,42010,42010,41960,41940,41920,41860,41840,41830,41810,41770,41750,41740,41720,41710,41700,41670,41680,41650,41640,41560,41520,41430,41210,41110,41080,39250,38880,38790,38770,38700,38680,38570,38560,38540,38460,38420,38110,37930,37900,37840,37820,37740,37750,37710,37690,37580,37060,37030,34450,34430,34340,34310,34260,34250,34220,34130,34110,34062,34050,31860,31830,31640,31610,31560,31531,31521,31371,31353,31181,31160,31114,31101,31081,31060,31020,38000,38010,38090,38520];

var fhair1 = [44611,44520,44516,44420,37321,34872,34211,44400,41540,38930,44110,44070,44060,44050,44040,42090,42070,42010,42010,41960,41940,41920,41860,41840,41830,41810,41770,41750,41740,41720,41710,41700,41670,41680,41650,41640,41560,41520,41430,41210,41110,41080,39250,38880,38790,38770,38700,38680,38570,38560,38540,38460,38420,38110,37930,37900,37840,37820,37740,37750,37710,37690,37580,37060,37030,34450,34430,34340,34310,34260,34250,34220,34130,34110,34062,34050,31860,31830,31640,31610,31560,31531,31521,31371,31353,31181,31160,31114,31101,31081,31060,31020,38000,38010,38090,38520];

//男脸型
var mface = [26360,23080,25629,20043,20067,25000,23030,20152,23176,20044,20035,23116,20033,23128,23183,20046,25019,25121,20061,20011];

var mface1 = [26360,23080,25629,20043,20067,25000,23030,20152,23176,20044,20035,23116,20033,23128,23183,20046,25019,25121,20061,20011];

//女脸型
var fface = [26360,24078,21112,21042,24002,24127,21194,24027,21082,21236,24010,24188,26227,25617,24139,25403,24122,24036,21025,26234,25104,24235,21149,21062,26142,24631,24732,21250,24058,21070,26012,21144,21079,21033,26125,24198,21028,21031,21033,24171];

var fface1 = [26360,24078,21112,21042,24002,24127,21194,24027,21082,21236,24010,24188,26227,25617,24139,25403,24122,24036,21025,26234,25104,24235,21149,21062,26142,24631,24732,21250,24058,21070,26012,21144,21079,21033,26125,24198,21028,21031,21033,24171];

//皮肤代码
var skin = [0, 1, 2, 3, 4];

var beauty = 0;
var hair_Colo_new;
var face_Colo_new;
var one = "#fUI/UIPVP.img/UserRanking/NumRank/Survival/1#";
var two = "#fUI/UIPVP.img/UserRanking/NumRank/Survival/2#";
var three = "#fUI/UIPVP.img/UserRanking/NumRank/Survival/3#";

function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 0) {
        cm.dispose();
        return;
    } else {
        status++;
    }
    if (status == 0) {
		text = "#b欢迎来到#r枫之谷沙龙中心#b。请选择你要享受的服务：\r\n";
		text+= "#b#L0#发型设计#d（收费，使用#r#z"+ Cash[0][1] +"##b可以免单～）#l\r\n";
		text+= "#b#L1#脸部护理#d（收费，使用#r#z"+ Cash[1][1] +"##b可以免单～）#l\r\n";
		text+= "#b#L2#发型染色#d（免费使用）#l\r\n";
		text+= "#b#L3#皮肤改色#d（免费使用）#l\r\n"
        cm.sendSimple(text);
    } else if (status == 1) {
        if (selection == 0) {
			beauty = 1;
			text = "#b#e请选择分类：#n（每次定制理发需要 #r"+ Cash[0][0] +" #b个余额）#k\r\n\r\n";
			text+= "\t #L0##r"+ one +" 随机发型 #l\t\t#L1##d"+ two +" 定制发型 #l\r\n\r\n\r\n";
			text+= "#d温馨提示：背包里有#v"+ Cash[0][1] +"##b#z"+ Cash[0][1] +"##d会优先被消耗#k";
			cm.sendSimple(text);
		} else if (selection == 1) {
			beauty = 2;
			text = "#b#e请选择分类：#n（每次定制理发需要 #r"+ Cash[1][0] +" #b个余额）#k\r\n\r\n";
			text+= "\t #L0##r"+ one +" 随机脸型 #l\t\t#L1##d"+ two +" 定制脸型 #l\r\n\r\n\r\n";
			text+= "#d温馨提示：背包里有#v"+ Cash[1][1] +"##b#z"+ Cash[1][1] +"##d会优先被消耗#k";
			cm.sendSimple(text);
        } else if (selection == 2) {
            var currenthaircolo = Math.floor((cm.getPlayerStat("HAIR") / 10)) * 10;
            hair_Colo_new = [];
            beauty = 3;
            for (var i = 0; i < 8; i++) {
                hair_Colo_new[i] = currenthaircolo + i;
            }
            cm.askAvatar("本服务免费～", hair_Colo_new, Cash, isSecond != 0);
        } else if (selection == 3) {
			beauty = 4;
			cm.sendStyle("本服务免费～", skin, Cash, isSecond != 0);
		}
    } else if (status == 2) {
        if (beauty == 1) {
			var hair = cm.getPlayerStat("HAIR");
            hair_Colo_new = [];

		if(selection == 0) {
		cm.dispose();
		cm.openNpc(9390213,2);
		}else if(selection == 1) {
			if (cm.getPlayerStat("GENDER") == 0) {
			    hair_Colo_new = mhair1;
			} else {
				hair_Colo_new = fhair1;
			}
		cm.askAvatar("亲爱的#b#h ##k，欢迎来到#r美发中心#k。洗剪吹一次需要 #r"+ Cash[0][0] +"#k 个余额喔。\r\n如果你有#v"+ Cash[0][1] +"##b#z"+ Cash[0][1] +"##k的话，我可以考虑给您免单喔！", hair_Colo_new, Cash, isSecond != 0);
			}
	  } else if (beauty == 2) {
		    var face = cm.getPlayerStat("FACE");
            if(selection == 0) {
		cm.dispose();
		cm.openNpc(9390213,1);
		}else if(selection == 1) {

			if (cm.getPlayerStat("GENDER") == 0) {
			    face_Colo_new = mface1;
			} else {
				face_Colo_new = fface1;
			}	
           cm.askAvatar("亲爱的#b#h ##k，欢迎来到#r滋养中心#k。脸部护理一次需要 #r"+ Cash[1][0] +"#k 个余额喔。\r\n如果你有#v"+ Cash[1][1] +"##b#z"+ Cash[1][1] +"##k的话，我可以考虑给您免单喔！", face_Colo_new, Cash, isSecond != 0);
		}


      } else if (beauty == 3) {
			cm.setHair(hair_Colo_new[selection]);
            cm.playerMessage(1,"使用成功");
			cm.dispose();
      } else if (beauty == 4) {
			cm.setSkin(skin[selection]);
            cm.playerMessage(1,"使用成功");
			cm.dispose();
            }
    } else if (status == 3) {
		if (beauty == 1) {
			if (cm.getPlayerStat("GM") == 1) {   //Gm免单检测
                cm.setHair(hair_Colo_new[selection]);
                cm.sendOk("#d您是尊敬的Gm，本店为您免单，祝您使用愉快～");
		  } else if (cm.setAvatar(Cash[0][1], hair_Colo_new[selection], isSecond != 0) == 1) {  //免单理发卡检测
                cm.sendOk("#b您使用#v"+ Cash[0][1] +"##d#z"+ Cash[0][1] +"##b成功设计好了造型～");
				cm.worldSpouseMessage(0x13,"『造型沙龙』：恭喜 "+ cm.getChar().getName() +" 造型设计成功，他/她变得更有型了～");
		  } else if (cm.getHyPay(1) >= Cash[0][0]) {  //余额检测
			    cm.addHyPay(Cash[0][0]);
                cm.setHair(hair_Colo_new[selection]);
				cm.playerMessage(- 1,"消耗 "+ Cash[0][0] +" 个余额");
				cm.worldSpouseMessage(0x13,"『造型沙龙』：恭喜 "+ cm.getChar().getName() +" 造型设计成功，他/她变得更有型了～");
                cm.sendOk("#b您花费了 #r"+ Cash[1][0] +" #b个余额成功设计好了造型～");			
          } else {
                cm.sendOk("#r对不起，您无法使用此功能：\r\n\r\n#b1)：余额不足 #r"+ Cash[0][0] +" #b个.\r\n2)：没有 #v"+ Cash[0][1] +"##d#z"+ Cash[0][1] +"##k.");
            }
			cm.dispose();
	 } else if (beauty == 2) {
		    if (cm.getPlayerStat("GM") == 1) {   //Gm免单检测
                cm.setFace(face_Colo_new[selection]);
                cm.sendOk("#d您是尊敬的Gm，本店为您免单，祝您使用愉快～");
		  } else if (cm.setAvatar(Cash[1][1], face_Colo_new[selection], isSecond != 0) == 1) {  //免单脸型卡检测
                cm.sendOk("#b您使用#v"+ Cash[1][1] +"##d#z"+ Cash[1][1] +"##b成功滋润了脸部肌肤～");
				cm.worldSpouseMessage(0x13,"『造型沙龙』：恭喜 "+ cm.getChar().getName() +" 滋养皮肤成功，他/她变得更焕发光彩了～");
		  } else if (cm.getHyPay(1) >= Cash[1][0]) {  //余额检测
			    cm.addHyPay(Cash[1][0]);
                cm.setFace(face_Colo_new[selection]);
				cm.playerMessage(- 1,"消耗 "+ Cash[1][0] +" 个余额");
				cm.worldSpouseMessage(0x13,"『造型沙龙』：恭喜 "+ cm.getChar().getName() +" 滋养皮肤成功，他/她变得更焕发光彩了～");
                cm.sendOk("#b您花费了 #r"+ Cash[1][0] +" #b个余额成功滋润了脸部肌肤～");				
          } else {
                cm.sendOk("#r对不起，您无法使用此功能：\r\n\r\n#b1)：余额不足 #r"+ Cash[1][0] +" #b个.\r\n2)：没有 #v"+ Cash[1][1] +"##d#z"+ Cash[1][1] +"##k.");
            }
			cm.dispose();
	    }

	}
}